package com.lhb.SC.web.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.lhb.SC.web.context.ResponseResult;
@Slf4j
@RestControllerAdvice
public class DefaultExceptionHandler {

	@ExceptionHandler(Throwable.class)
	@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
	@ResponseBody
	public ResponseResult<Object> customException(Throwable e) {
		log.error("请求失败",e);
		return ResponseResult.fail("1", "请求失败：" + e.getMessage());
	}
}
